<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>老师批改管理作业章节列表下学生列表</title>
  <link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" type="text/css" href="../css/api.css"/>
		<link rel="stylesheet" href="../../css/aui.css">
		<link rel="stylesheet" href="../../css/personal.css">
		<style>
			.mask {
				position: absolute;
				top: 0px;
				filter: alpha(opacity=60);
				background-color: #777;
				z-index: 1002;
				left: 0px;
				opacity: 0.5;
				-moz-opacity: 0.5;
			}
			.marklist {
				width: 25%;
				font-size: 60%
			}
			.width30_center {
				width: 30%;
				text-align: center;
			}
				.button_red {
				color:#F64E4E;
			
			}
			.button_blue {
				color: #18B4ED;
		
			}
	        .button_orange{
	       color:#F0AD4E;

	        }
		</style>
	</head>
	<body>
		<div id='mian'>
		
			<div class="aui-content aui-margin-b-15">
				<ul class="aui-list aui-list-in" id="quar_list">
			
				<!--<li class="aui-list-item certification ">
					<div class="aui-list-item-inner">
					<div class="aui-list-item-title  width30_center"  >
					白净
					</div>
				
					<div class="aui-list-item-title  width30_center " >
					分数 ：80
					</div>
					<div class="aui-list-item-title   width30_center" >
					
					<span  class="button_red">阅卷</span>
					</div>
					</div>
			
					</li>-->
				</ul>
			</div>
			<div id="mask" class="mask"></div>
		</div>
		<div class="noSign" hidden="hidden" id="noData">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button"  onclick="loadData()"class="mui-btn mui-btn-outlined">
				重新加载
			</button>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript">

		var page = 1;
		var row = 20;
		var refreshCount = 0;
//		var classid = 'normal';
		var pageParam ='';
		var classid ='';//班级id1
		var  status ='';
//		var sid  = '';//修改的学生
//		var stype ='';//修改后的状态
		//新请求到的数据条数
		apiready = function() {
         
			loadNewData();
			setRefreshHeader();
			setPullUpRefresh();
			 ReceNotifi();
			 ReceNotifilist();
			$("#mask").click(function() {
				$("#mask").hide();
				api.sendEvent({
					name : 'close_mask'
				});
			});
//			SendBehaviorTrajectoriesNotifi(0, '查看作业列表', '065');
		}
		//更改批注状态
		function ReceNotifilist(){
		api.addEventListener({
	        name:'Teach_freecourse_homeworks'
        },function(ret,err){
         if(ret){
           var type = ret.value.type;
          var sid = ret.value.sid;
          var stuname = ret.value.name;
          var score = ret.value.score;
          var typeStr;
          if(type==1){//驳回
			typeStr='<span  class="button_orange" >驳回</span>';
			}else if(type==2){//已审阅
			typeStr='<span  class="button_blue" >已阅</span>';
			 $('#'+sid).find('#score').text(score+'分');
			}

			 $('#'+sid).find('#status').html(typeStr);
		
          }
        	//coding...
        });
		}
		function ReceNotifi() {
			api.addEventListener({
				name : 'mark_show'
			}, function(ret, err) {
				$("#mask").css("height", $(document).height());
				$("#mask").css("width", $(document).width());
				$("#mask").show();
			});
			//关闭蒙版
			api.addEventListener({
				name : 'mark_close'
			}, function(ret, err) {
				//coding...
			
				//关闭蒙层
				$("#mask").hide();
			});
			//分类
			api.addEventListener({
				name : 'item_point'
			}, function(ret, err) {
		        if(ret){
		        page = 1;
//		    alert("学生"+JSON.stringify(ret.value.data)+"=="+ret.value.type);
			     //滑动到顶部
			      api.pageUp({top:true},function(ret, err) {
                    });
					var data = ret.value.data;
					var type = ret.value.type;
					if (type == 0) {//班级
					   
						classid = data.id;
					
					 if(classid == 'normal'){
						 classid = '';
					    }
					    status ='';
						
					} else if (type == 1) {//类型
					  var id= data.id
					  if(id == 0){
					  status ='';
					  }else if(id == 1){//以申审阅
					  status =2;
					  }else if(id == 2){//审阅
					   status =0;
					  }else if(id == 3){//驳回
					   status =1;
					  }
				
						
					}
					loadNewData();
				}
			});
		}

		function loadNewData() {
			page = 1;
			loadData();
		}

		function loadMoreData() {
			page++;
			loadData();
		}

		//获取班级学生列表
		function loadData() {
		  showProgress();
	     pageParam = api.pageParam;
	    
			var params = {
				jid : $api.getStorage('cfnetppjxid'),
				//uid:"11924",
				uid:$api.getStorage('cfnetppuid'),
				cid : pageParam.cid,
				vid : pageParam.vid,
				pid : pageParam.pid,
				wid: pageParam.wid,
			    classid : classid,//班级
                status : status,// 作业批改状态 
                page:page,
                rows: row
			};
			
			cfnetppPOST(url_getClassWorkList, params, true, function(data, status) {
//				alert(JSON.stringify(params));
				api.hideProgress();
				api.refreshHeaderLoadDone();
				if (status == 'success') {
					if (data.code == 200) {
						var students = data.data.list;
						refreshCount = data.data.total;

						if (students != '' && students.constructor == Array && students.length > 0) {
							$('#noData').hide();
							$('#noNet').hide();
							$('#mian').show();
							writelist(students,students.length);
						} else {
							$('#noData').show();
							$('#noNet').hide();
//							api.toast({
//								msg : '该章节下暂无学生'
//							});
						}
					} else if (data.code = 109) {
					 if(page ==1){
						$('#noData').show();
						$('#noNet').hide();
							$('#mian').hide();
       				    }
					} else {
					if(page ==1){
						$('#noData').show();
						$('#noNet').hide();
						$('#mian').hide();
						}

					}
				} else {
					$('#noData').hide();
					$('#noNet').show();
				   $('#mian').hide();
//					api.toast({
//						msg : '获取学生列表失败'
//					});
				}
			});
		}

		function writelist(quar_list,len) {

			var data = '';
			var strhtml = '';
			var typeStr='';
			var IdStr='';
		
			for (var i = 0; i < len; i++) {
				data = quar_list[i];
				 var score='';
				if(data.status==0){//未审阅
				typeStr='<span id="status"><span  class="button_red" >未阅</span></span>';

				}else if(data.status==1){//驳回
				typeStr='<span id="status"><span  class="button_orange">驳回</span></span>';
				}else if(data.status==2){//已审阅

				  typeStr='<span id="status"><span  class="button_blue " >已阅</span></span>';
					if(data.score != null){
					 score=data.score+'分';
					}
				}
			  
				
				var str = '<li  id=' + data.studyid + '  class="aui-list-item certification" onclick="itemclicl('+"'"+data.rename+"'"+","+data.studyid+","+data.status+')" >' 
				+ '<div class="aui-list-item-inner" >' 
				+ '<div class="aui-list-item-title   width30_center base_dark_grey" >' 
				+ data.rename
				+ '</div>' 
				+ '<div class="aui-list-item-title   width30_center base_dark_grey"><span id="score">' 
				+ score
				+ '</span></div>' 
				+ '<div class="aui-list-item-title   width30_center" >' 
				+ typeStr 
				+ '</div>' 
				+ '</div>' 

				 + '</li>';
				strhtml = strhtml + str;
			}
		
			if (page == 1) {
				$('#quar_list').html(strhtml);
			} else {
				$('#quar_list').append(strhtml);
			}
		}
		function itemclicl(name,studyid,type) {
       var type1 = $('#'+studyid).find('#status').children('span').text()+'';
     
		if(type1 == '未阅'){
			api.openWin({useWKWebView:true,
					name : 'Teach_freecourse_homeworks',
					url : 'Teach_freecourse_homeworks.html',
					pageParam : {
					name:name,
					studyid:studyid,
				    cid : pageParam.cid,
				    vid : pageParam.vid,
				    pid : pageParam.pid,
				    wid: pageParam.wid,
				    opentype:1,
					},
				
					slidBackEnabled: false,
				bounces : false,
				vScrollBarEnabled : false,
				hScrollBarEnabled : false
						});
		}else{
		  api.openWin({useWKWebView:true,
			name : 'Teach_freecourse_homeworkinfo',
			url : 'Teach_freecourse_homeworkinfo.html',
			pageParam : {
					name:name,
					studyid:studyid,
				   cid : pageParam.cid,
				   vid : pageParam.vid,
				   pid : pageParam.pid,
				    wid: pageParam.wid,
				     opentype:1,
					},
					slidBackEnabled: false,
				bounces : false,
				vScrollBarEnabled : false,
				hScrollBarEnabled : false
					});
		}
//SendBehaviorTrajectoriesNotifi(1, '查看作业列表', '065');
		}
	</script>
</html>